package com.sd.repay.thread;

import com.sd.repay.common.CommonResult;
import com.sd.repay.service.AroundPayOrderService;
import com.sd.repay.utils.JsonUtil;
import com.sd.repay.utils.SpringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description: 交易订单分销线程
 * @date 2018年09月25日
 */
public class PayOrderDistribThread implements Runnable {

    private static final Logger log = LoggerFactory.getLogger(PayOrderDistribThread.class);

    private AroundPayOrderService aroundPayOrderService = SpringUtil.getBean(AroundPayOrderService.class);

    private String orderNo;

    public PayOrderDistribThread(String orderNo) {
        super();
        this.orderNo = orderNo;
    }

    @Override
    public void run() {
        try {
            log.info("交易订单[{}]成功准备计算商户分销入账", new Object[]{orderNo});
            CommonResult profitRes = aroundPayOrderService.orderSuccToMerDistrib(orderNo);
            log.info("交易订单[{}]成功计算商户分销入账结果[{}]", new Object[]{orderNo, JsonUtil.objectToJson(profitRes)});
        } catch (Exception e) {
            log.error("交易订单[{}]计算商户分销入账异常[{}]", new Object[]{orderNo, e});
        }
    }
}